<template>
    <div style="display:flex;align-items: center;;">
        <el-switch
            style="display: block"
            v-model="action"
            active-color="#13ce66"
            inactive-color="#ff4949"
            @change="stationSwitchPost"
            active-text="启用"
            inactive-text="禁用">
        </el-switch>
    </div>
</template>


<script>
import { api } from "@/utils/api";

export default {
    data() {
      return {
        action: true
      }
    },
    props: ['paramsInfo'],
    methods: {
        async stationSwitchPost(value) {
            console.log('value', value, this.action);
            let params = {
                app_name: "gui",
                data: {
                 ...this.paramsInfo,
                 Action: !this.action? 'off':'on',
                }
            }
            let [ERR, ARES] = await api.stationSwitch(params);
            if (ARES.code === 0) {
                this.$message({
                    type: "success",
                    message: ARES.message,
                });
            } else {
                this.$message({
                    type: "warning",
                    message: ARES.message,
                });
            }
            console.log('stationSwitchPost', ARES);
        }
    }
  };
</script>